package com.rongc.client.freight.base.view.adapter;

import android.content.Context;
import android.view.View;

import com.bumptech.glide.Glide;
import com.rongc.client.core.utils.StringUtils;
import com.rongc.client.freight.R;
import com.rongc.client.freight.base.model.BaseDic;
import com.rongc.client.freight.business.mine.model.CarDic;

import java.util.HashMap;
import java.util.List;

/**
 * Created by ccqx on 2017/6/28.
 */

public class RecyclerAuthAdapter extends RecyclerBaseAdapter<HashMap<String,String>>{


    public RecyclerAuthAdapter(Context mContext, List<HashMap<String, String>> mDatas) {
        super(mContext, mDatas);
    }

    @Override
    protected void onBind(final BaseRecyclerViewHolder holder, int position, HashMap<String, String> data) {

        holder.setText(R.id.tv_idcard,data.get("name"));
        if(StringUtils.isEmpty(data.get("image")))    {
            holder.getImageView(R.id.iv_idcard).setVisibility(View.GONE);
        }else {
            holder.getImageView(R.id.iv_idcard).setVisibility(View.VISIBLE);
//            holder.getImageView(R.id.iv_idcard).setImageURI(Uri.fromFile(new File(data.get("image"))));
            Glide.with(mContext.getApplicationContext())
                    .load(data.get("image"))
                    .placeholder(R.mipmap.auth_icon)
                    .into(holder.getImageView(R.id.iv_idcard));

        }

        switch (data.get("id")){
            case BaseDic.AuthType.IDCARD_TYPE:
                holder.setImageResource(R.id.iv_icon,R.mipmap.universal_example_sfz);
                break;
            case BaseDic.AuthType.DRIVING_TYPE:
                holder.setImageResource(R.id.iv_icon,R.mipmap.universal_example_jsz);
                break;
            case BaseDic.AuthType.GROUP_TYPE:
                holder.setImageResource(R.id.iv_icon,R.mipmap.universal_example_hy);
                break;
            case BaseDic.AuthType.YYZZ_TYPE:
                holder.setImageResource(R.id.iv_icon,R.mipmap.universal_example_yyzz);
                break;
            case CarDic.PhotoType.DRIVING_TYPE:
                holder.setImageResource(R.id.iv_icon,R.mipmap.universal_example_xsz);
                break;
            case CarDic.PhotoType.HEAD_TYPE:
                holder.setImageResource(R.id.iv_icon,R.mipmap.universal_example_ct);
                break;
            case CarDic.PhotoType.BODY_TYPE:
                holder.setImageResource(R.id.iv_icon,R.mipmap.universal_example_cs);
                break;
            case CarDic.PhotoType.TAIL_TYPE:
                holder.setImageResource(R.id.iv_icon,R.mipmap.universal_example_cw);
                break;
        }


    }

    @Override
    protected int getLayoutId() {
        return R.layout.recycler_auth_item;
    }
}
